<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var isPalindrome = function (x) {
            if (x >= 0 && x < 10) {
                return true
            }
            if (x < 0) { 
                console.log(123);
                return false 
            }
            let strX = x.toString()
            let len = strX.length
            if (len % 2 === 0) {
                for (let i = 0; i < len / 2; i++) {
                    if (strX[i] !== strX[len - i - 1]) {
                        return false
                    }
                }
                return true
            } else {
                for (let i = 0; i < (len - 1) / 2; i++) {
                    if (strX[i] !== strX[len - i - 1]) {
                        return false
                    }
                }
                return true
            }
        };

        console.log(isPalindrome(-121));
    </script>
</body>

</html>